// index.js
// 获取应用实例
var app = getApp()

Page({
  data: {
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },

  onLoad() {
    this.getList();
  },

  goDetail: function(e){
    console.log(e);
    var mid = e.currentTarget.dataset.mid;
    wx.navigateTo({
      url: 'detail?mid=' + mid,
    })
  },

  getList: function(){
    var that = this;
    app.util.request({
      url: 'entry/wxapp/merchantList',
      data: {
      },
      cachetime: 30,
      success: function (res) {
        if(res.data.errno == 0){
          that.setData({
            list: res.data.data.list
          });
          wx.stopPullDownRefresh();
        }
      },
      fail: function (res) {
        wx.showToast({
          title: res.data.message,
          icon: 'none',
          duration: 2000
        });
        return false;
      }
    })
  },

  onPullDownRefresh: function () {
    this.getList();
  },
})
